package com.rfs.suanfa;

import java.util.stream.IntStream;

public class 删除排序数组中的重复项 {
    public static void main(String[] args) {
        int[] num = {1, 1, 2};
        removeDuplicates(num);
    }

    public static int removeDuplicates(int[] nums) {
        int length = nums.length;
        if (length == 0) {
            return 0;
        }
        int fast =1;
        int slow=1;
        while (fast < length) {
            if (nums[fast] != nums[fast - 1]) {
                nums[slow] = nums[fast];
                slow++;
            }
            fast++;
        }
        return slow;
    }
}
